package main

import (
	"fmt"
	"net"
	"time"
)

func SendTCPCommand(ip string, port int, cmd string) error {
	address := fmt.Sprintf("%s:%d", ip, port)

	conn, err := net.DialTimeout("tcp", address, 3*time.Second)
	if err != nil {
		return err
	}
	defer conn.Close()

	_, err = conn.Write([]byte(cmd))
	if err != nil {
		return err
	}

	return nil
}
